package sample.testTickManager
{
	import org.abc.uiCore.AbcView;
	import org.abc.interfaces.ITick;
	import flash.display.Shape;

	/**
	 * @描述
	 * @作者		Mr.zheng
	 * @版本		version 1.0
	 * @创建日期	2011-7-31 11:15
	 */
	public class Ball extends Shape implements ITick
	{
		private var _isPlay:Boolean;
		private var _startTime:int;
		private var _executeTime:int;
		private var _tickGap:int;

		private var _vx:int;
		private var _vy:int;

		public function Ball()
		{
			this.graphics.clear();
			this.graphics.beginFill(0x000000, 1);
			this.graphics.drawCircle(0, 0, 10);
			this.graphics.endFill();
			this.cacheAsBitmap=true;
			randomSpeed();
		}

		private function randomSpeed():void
		{
			_vx=Math.random() * 4 - 2;
			_vy=Math.random() * 4 - 2;
			if (_vx == 0 && _vy == 0)
			{
				randomSpeed();
			}
		}

		/* INTERFACE blog.zihua2007.interfaces.ITick */
		public function tick():void
		{
			this.x+=_vx;
			this.y+=_vy;
			if (this.x > this.stage.stageWidth || this.x < 0 || this.y < 0 || this.y > this.stage.stageHeight)
			{
				this.x=int(Math.random() * stage.stageWidth);
				this.y=int(Math.random() * stage.stageHeight);
				randomSpeed();
			}
		}

		public function get startTime():int
		{
			return _startTime;
		}

		public function set startTime(value:int):void
		{
			_startTime=value;
		}

		public function get executeTime():int
		{
			return _executeTime;
		}

		public function set executeTime(value:int):void
		{
			_executeTime=value;
		}

		public function get tickGap():int
		{
			return _tickGap;
		}

		public function set tickGap(value:int):void
		{
			_tickGap=value;
		}

		public function get isPlay():Boolean
		{
			return _isPlay;
		}

		public function set isPlay(value:Boolean):void
		{
			_isPlay=value;
		}

	}
}
